package com.zorn.platform.role.service.impl;

import java.util.List;
import java.util.Map;

import org.apache.commons.collections.MapUtils;
import org.springframework.stereotype.Service;

import com.zorn.core.provider.ServiceSupportProvider;
import com.zorn.platform.role.service.IRoleComponentService;
import com.zorn.platform.role.dao.RoleComponentDao;
import com.zorn.platform.user.service.IUserRoleService;

@Service
public class RoleComponentService extends ServiceSupportProvider implements IRoleComponentService {

	/* Fields
	================================================== */
	private RoleComponentDao roleComponentDao;

	/* Methods
	================================================== */
	public List<Map<String, Object>> query(Map<String, Object> params) {
		List<Map<String, Object>> data = roleComponentDao.query(params);

		return setQueryResult(isPaging() ? roleComponentDao.count(params) : data.size(), data);
	}

	public int count(Map<String, Object> params) {
		return setCountResult(roleComponentDao.count(params));
	}

	public String insert(Map<String, Object> params) {
		return setInsertResult(roleComponentDao.insert(params), MapUtils.getString(params, "role_id"));
	}

	public int update(Map<String, Object> params) {
		return setUpdateResult(roleComponentDao.update(params));
	}

	public int delete(Map<String, Object> params) {
		return setDeleteResult(roleComponentDao.delete(params));
	}

	@Override
	public List<Map<String, Object>> getComponents(Map<String, Object> params) {
		final IUserRoleService userRoleService = (IUserRoleService) getBean(IUserRoleService.class);
		
		return null;
	}

	/* Getters & Setters
	================================================== */
	public void setRoleComponentDao(RoleComponentDao roleComponentDao) {
		this.roleComponentDao = roleComponentDao;
	}

}